package com.supreme.proxyserver.controller;

import com.supreme.commonmybatis.mapper.MBGroupMapper;
import com.supreme.commonmybatis.entity.primary.MBGroup;
import com.supreme.commonboot.utils.AjaxResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "group")
public class GroupController {

    @Resource
    private MBGroupMapper mbGroupMapper;

    @PostMapping(value = "create")
    public AjaxResp createGroup(@RequestBody MBGroup group) {
        final int insert = mbGroupMapper.insert(group);
        return new AjaxResp(insert);
    }

    @GetMapping(value = "selectGroupOne/{groupId}")
    public AjaxResp selectGroupOne(@PathVariable(value = "groupId") Long groupId) {
        final MBGroup groupOne = mbGroupMapper.selectGroupOne(groupId);
        return new AjaxResp(groupOne);
    }

    @GetMapping(value = "selectGroupList")
    public AjaxResp selectGroupList() {
        final List<MBGroup> groupList = mbGroupMapper.selectGroupList();
        return new AjaxResp(groupList);
    }
}
